<?php

namespace App\Models\Base;

use Illuminate\Database\Eloquent\Model;

class LogEmail extends Model
{
    protected $fillable = ['server_id', 'recipient_type', 'recipients', 'title', 'content', 'status', 'admin_name'];

    public function serverName()
    {
        return $this->hasOne(ServerList::class, 'server_id', 'server_id');
    }

    public function emailItem()
    {
        return $this->hasMany(EmailItem::class, 'log_email_id');
    }

    public function setRecipientsAttribute($value)
    {
        $this->attributes['recipients'] = join(',', $value);
    }
}
